////////////////////////////////////////////////////////////////////////////////
// Copyright 2006 CORE Solutions Limited
// All rights reserved.
// PROPRIETARY AND CONFIDENTIAL INFORMATION.
// Use is subject to license terms.
//
// FUNCTION ID      :   SimpleSearchStyleActionTemplate.java
// AUTHOR           :   ric.yik
// DATE CREATE      :   2006/5/5
// DESCRIPTION      :   
//                  :   
//                  :   
//                  :   
//
// MODIFICATION HISTORY:
// DATE         AUTHOR          VERSION NO.         COMMENT
// -----------  --------------  ------------------  -------------------
// 2006/5/5      ric.yik         1.0                 source is created.
//
//
//
////////////////////////////////////////////////////////////////////////////////

package com.erp.framework.controller.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.erp.common.web.ActionMethodDispatcher;
import com.erp.framework.controller.form.SimpleSearchStyleForm;
import com.erp.framework.util.logger.Logger;

public abstract class SimpleSearchStyleActionTemplate extends SimpleSearchStyleAction {

    protected ActionForward handlePageEvent(ActionMapping mapping, ActionForm formIn, HttpServletRequest request,
            HttpServletResponse response, ActionErrors errors) {
        ActionForward actionForward = new ActionForward(mapping.getInput());
        if (this.isHandled(request)) {
            return actionForward;
        }
        try {
            SimpleSearchStyleForm form = (SimpleSearchStyleForm) formIn;
            actionForward = new ActionMethodDispatcher()
                .setAction(this)
                .setDefaultActionForward(actionForward)
                .processAction(form.getPageEvent(), mapping, form, request, response, errors);
        } catch (Exception e) {
            Logger.logExceptions(this, e);
        }
        this.saveToken(request);
        this.setHandled(request);
        return actionForward;
    }

    protected ActionForward processOtherStatus(ActionMapping mapping, ActionForm formIn, HttpServletRequest request,
            HttpServletResponse response, ActionErrors errors, String rb_status) {
        ActionForward actionForward = new ActionForward(mapping.getInput());
        try {
            SimpleSearchStyleForm form = (SimpleSearchStyleForm) formIn;
            actionForward = new ActionMethodDispatcher()
                .setAction(this)
                .setDefaultActionForward(actionForward)
                .setProcessStatus(true)
                .setStatus(rb_status)
                .processAction(form.getPageEvent(), mapping, form, request, response, errors);
        } catch (Exception e) {
            Logger.logExceptions(this, e);
        }
        this.saveToken(request);
        this.setHandled(request);
        return actionForward;
    }

    protected String getSimpleSrchMenuId(ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response) {
        return this.getModuleName(mapping, formIn, request, response);
    }

}
